import axios from "./axios";
import { getLocalStroage } from "@/utils/localStorage";

export function eqCordGetKey() {
  return axios({
    url: "/login/qr/key",
    params: {
      t: Date.parse(new Date()) / 1000,
    },
  });
}

export function eqCordCreate(key, qrimg) {
  return axios({
    url: "/login/qr/create",
    params: {
      key,
      qrimg,
      t: Date.parse(new Date()) / 1000,
    },
  });
}

export function eqCordCheck(key) {
  return axios({
    url: "/login/qr/check",
    params: {
      key,
      t: Date.parse(new Date()) / 1000,
    },
  });
}
// 邮箱登录
export function emailLogin(email, md5_password) {
  return axios({
    url: "/login",
    params: {
      email,
      md5_password,
    },
  });
}
// 获取国家区号
export function countriesCodeList() {
  return axios({
    url: "/countries/code/list",
  });
}
// 手机登录
export function phonePassword(phone, md5_password) {
  return axios({
    url: "/login/cellphone",
    params: {
      phone,
      md5_password,
    },
  });
}
// 手机登录(验证码)

export function phoneCaptcha(phone, captcha) {
  return axios({
    url: "/login/cellphone",
    params: {
      phone,
      captcha,
    },
  });
}
// 发送验证码
export function sendCaptchaSent(phone, ctcode) {
  return axios({
    url: "/captcha/sent",
    params: {
      phone,
      ctcode,
    },
  });
}
// 验证验证码

export function captchaVerify(phone, captcha) {
  return axios({
    url: "/captcha/verify",
    params: {
      phone,
      captcha,
    },
  });
}
// 登录状态
export function loginStatus() {
  return getLocalStroage("cookie")
    ? axios({
        url: "/login/status?cookie=" + getLocalStroage("cookie"),
      })
    : [];
}
// 获取私信
export function getMsgPrivate() {
  return getLocalStroage("cookie")
    ? axios({
        url: "/msg/private?cookie=" + getLocalStroage("cookie"),
      })
    : [];
}
export function refresh() {
  return axios({
    url: "/login/refresh",
  });
}
